<template>
  <div class="login-container">
    <el-form :model="userOpt" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
      <el-form-item lable="账号" prop="user">
        <el-input v-model="userOpt.user" placeholder="请输入内容"></el-input>
      </el-form-item>
        <el-form-item lable="密码" prop="pwd">
        <el-input v-model="userOpt.pwd" placeholder="请输入内容"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
        <el-button @click="resetForm('ruleForm')">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
// import axios from 'axios'
export default {
  data() {
    return {
      userOpt: {
        user: '',
        pwd: ''
      },
      rules: {
        user: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
        pwd: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    submitForm(formName) {

      // 请求接口 获取token
      // const token = 'test-123'
      // localStorage.setItem('token', token)
      // // 跳转页面，导航守卫

      // console.log('formName:', formName)
      // this.$refs[formName].validate((valid) => {
      //   console.log('valid:', valid)
      //   if (valid) {
      //     alert('submit!');
      //   } else {
      //     console.log('error submit!!');
      //     return false;
      //   }
      // });
    },
    resetForm(formName) {
      // this.$refs[formName].resetFields();
    }
  },
  mounted() {
    // console.log('axios', axios)
    // axios.get('/api/index/index').then(res => {
    //   console.log('res', res)
    // })
    // axios.post('http://xinghen.51vip.biz/auth/oauth/token?username=admin&password=admin123&codeStart=1&client_secret=123456&grant_type=password&scope=server&client_id=web').then(res => {
    //   console.log('res')
    // })
  }
}
</script>

<style>

</style>
